package com.cskaoyan.service;

import com.cskaoyan.dao.OrderDao;
import com.cskaoyan.dao.UserDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.annotation.Resource;

/**
 * @author stone
 * @date 2022/04/26 10:25
 */
@Service
//@Scope("prototype")
public class UserServiceImpl implements UserService{

    //String username = "songge";
    //@Value("songge")
    @Value("${demo1.username}")
    String username;

    @Autowired
    @Qualifier("userDaoImpl1")
    UserDao userDao1;
    //@Autowired
    //@Qualifier("userDaoImpl2")
    @Resource(name = "userDaoImpl2")
    UserDao userDao2;
    @Autowired
    OrderDao orderDao;


    @Override
    public void sayHello() {
        System.out.println("hello " + username);
    }

    @PostConstruct
    public void init() {
        System.out.println("自定义的init方法");
    }
    @PreDestroy
    public void destroy() {
        System.out.println("自定义的destroy方法");

    }
}
